package com.example.demo1.filter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

/**
 * @author sunjk
 * @since 2020/9/7
 */
@Configuration
public class FilterConfig  {

    @Autowired
    private SecondFilter secondFilter;

    private String[] patterns= {"/*", "/*"};

    @Bean
    public FilterRegistrationBean getFilter() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(secondFilter);
        registrationBean.setUrlPatterns(Arrays.asList(patterns));
        registrationBean.setOrder(1);
        return registrationBean;
    }
}
